home *** CD-ROM | disk | FTP | other *** search
- (*===========================================================================*)
- (* Auxiliary task *)
- (* *)
- (* Copyright 1988, 1989, 1990, 1991, 1992 by H. Roy Engehausen. All *)
- (* rights reserved. *)
- (* *)
- (*===========================================================================*)
-
- UNIT BBAUX;
-
- INTERFACE
-
- PROCEDURE aux_task_start;
-
- VAR
- time_mon : LONGINT;
- found_mon : BOOLEAN;
-
- IMPLEMENTATION
-
- USES
- bbauxm,
- bbbcst,
- bbdummy,
- bblog,
- bblstr,
- bbmdata,
- bbmess,
- bbmf,
- bbmisc,
- bbmisci,
- bbmisc4,
- bbmon,
- bbrdata,
- bbsdata,
- bbsess,
- bbsrt,
- bbstr,
- bbtask,
- bbtime,
- bbuser,
- bbwin;
-
- (*===========================================================================*)
- (* Never ending loop that runs the aux process *)
- (*===========================================================================*)
-
- PROCEDURE aux_task_start;
-
- VAR
- clean_count : BYTE;
- delay_count : BYTE;
- do_speed : BOOLEAN;
- master_mon : BOOLEAN;
- modem_port : BOOLEAN;
- t_str : STRING[4];
- this_port : port_block_ptr;
- time_bcst : LONGINT;
-
- {$I 8250CON.PAS}
- {$I BBAUXI.PAS} (* Check inactive *)
- {$I BBAUXR.PAS} (* Telephone ring *)
-
- BEGIN;
-
- (*-----------------------------------------------------------------------*)
- (* Allow master task to regain control to build my control block *)
- (*-----------------------------------------------------------------------*)
-
- task_switch;
-
- (*-----------------------------------------------------------------------*)
- (* Set up master *)
- (*-----------------------------------------------------------------------*)
-
- master_mon := NOT found_mon;
- found_mon := TRUE;
-
- (*-----------------------------------------------------------------------*)
- (* Set up some switches *)
- (*-----------------------------------------------------------------------*)
-
- modem_port := (active_port^.port_type = port_modem)
- OR (active_port^.port_type = port_null_modem);
-
- clean_count := 1;
-
- (*-----------------------------------------------------------------------*)
- (* Prep broadcast time *)
- (*-----------------------------------------------------------------------*)
-
- IF (NOT modem_port)
- AND (active_port^.port_bcst OR (active_port^.rel_port <> NIL)) THEN
- time_bcst := 5
- ELSE
- time_bcst := max_time;
-
- (*-----------------------------------------------------------------------*)
- (* Get ready for loop *)
- (*-----------------------------------------------------------------------*)
-
- delay_count := 1;
- do_speed := FALSE;
-
- (*-----------------------------------------------------------------------*)
- (* Main loop *)
- (*-----------------------------------------------------------------------*)
-
- WHILE TRUE DO
- WITH active_tcb^ DO
- BEGIN;
-
- (*-----------------------------------------------------------------*)
- (* Force a switch. *)
- (*-----------------------------------------------------------------*)
-
- task_switch;
-
- (*-----------------------------------------------------------------*)
- (* Monitor the port. Don't do modems, subports or when operator *)
- (* is connected to monitor port *)
- (*-----------------------------------------------------------------*)
-
- IF (NOT modem_port)
- AND (NOT active_port^.port_sub_port)
- AND (active_port^.connected^[0] = NIL) THEN
- BEGIN;
-
- (*-------------------------------------------------------------*)
- (* Poll the port. Skip monitor if no data *)
- (*-------------------------------------------------------------*)
-
- send_recv_tnc(2);
-
- IF NOT active_tcb^.tnc_null THEN
- monitor_all;
-
- END;
-
- (*-----------------------------------------------------------------*)
- (* If it has been a while then do the waiting things *)
- (*-----------------------------------------------------------------*)
-
- IF delay_count > 15 THEN
- BEGIN;
-
- (*-------------------------------------------------------------*)
- (* Reset the delay *)
- (*-------------------------------------------------------------*)
-
- delay_count := 0;
-
- (*-------------------------------------------------------------*)
- (* Do a broadcast *)
- (*-------------------------------------------------------------*)
-
- IF (time_bcst < up_time) THEN
- BEGIN;
-
- (*---------------------------------------------------------*)
- (* Send the broadcast *)
- (*---------------------------------------------------------*)
-
- send_any_broadcasts;
-
- (*---------------------------------------------------------*)
- (* Schedule next broadcast *)
- (*---------------------------------------------------------*)
-
- time_bcst := up_time_from_now(60 * opt_block.bcst_interval);
-
- END;
-
- (*-------------------------------------------------------------*)
- (* Check the inactive channels to see if they want anything *)
- (*-------------------------------------------------------------*)
-
- IF NOT modem_port THEN
- check_inact
- ELSE
- check_ring;
-
- (*-------------------------------------------------------------*)
- (* Sync the log *)
- (*-------------------------------------------------------------*)
-
- IF master_mon AND (up_time > log_time) THEN
- log_sync;
-
- (*-------------------------------------------------------------*)
- (* Sync the monitor *)
- (*-------------------------------------------------------------*)
-
- IF master_mon AND (time_mon < up_time) THEN
- monitor_up;
-
- END; (*----- End Only-once-in-a-while Actions -------------------*)
-
- INC(delay_count);
-
- END; (*----- End never-ending loop ------------------------------------*)
-
- END;
-
- BEGIN;
-
- found_mon := FALSE;
-
- END.